package com.fancy.learncenter.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.LinearLayout;

import com.fancy.learncenter.activity.base.BaseActivity;
import com.fancy.learncenter.bean.BaseDataBean;
import com.fancy.learncenter.bean.LoginDataBean;
import com.fancy.learncenter.common.MyApplication;
import com.fancy.learncenter.net.HttpMehtod;
import com.fancy.learncenter.net.IdeaObserver;
import com.fancy.learncenter.utils.LogUtil;
import com.fancy.learncenter.utils.SPUtils;
import com.fancy.learncenter.utils.TimeUtil;
import com.fancy.learncenter.utils.Utils;
import com.superservice.lya.R;
import com.umeng.analytics.MobclickAgent;

import org.w3c.dom.Text;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import butterknife.Bind;
import butterknife.ButterKnife;

public class SplashActivity extends BaseActivity {

    @Bind(R.id.backgroup)
    LinearLayout backgroup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash, Status.NAVIGATION);
        ButterKnife.bind(this);


        if (false) {
//        if (SPUtils.isFirst()) {
            SPUtils.first(false);
            TimeUtil.interval(2, new TimeUtil.TimeCallBack() {
                @Override
                public void nextCallBack(long time) {
                }

                @Override
                public void completeCallBack() {
                    Intent intent = new Intent(SplashActivity.this, GuideActivity.class);
                    startActivity(intent);
                    finish();
                }

                @Override
                public void startCallBack() {

                }
            });
        } else if (TextUtils.isEmpty(SPUtils.getToken())) {
            TimeUtil.interval(2, new TimeUtil.TimeCallBack() {
                @Override
                public void nextCallBack(long time) {
                }

                @Override
                public void completeCallBack() {
                    Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }

                @Override
                public void startCallBack() {

                }
            });
        } else {


            MyApplication.userId = SPUtils.getUserID();
            MyApplication.token = SPUtils.getToken();

            MobclickAgent.onProfileSignIn(MyApplication.userId);
            Utils.loginRongYun();

            TimeUtil.interval(2, new TimeUtil.TimeCallBack() {
                @Override
                public void nextCallBack(long time) {
                }

                @Override
                public void completeCallBack() {

                    Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }

                @Override
                public void startCallBack() {

                }
            });
        }


    }

}
